package com.le.tester.javaThink.fifth.chapter12_Collections;

import java.util.ArrayDeque;
import java.util.Deque;

/**
 * createTime：2021/8/30 11:11
 * description：泛型的stack
 */
public class Stack<T> {
    private Deque<T> storage = new ArrayDeque<>();

    public void push(T v) {
        storage.push(v);
    }

    //拿出栈顶的元素，并不会删除
    public T peek() {
        return storage.peek();
    }

    //拿出栈顶的元素，进行删除
    public T pop() {
        return storage.pop();
    }

    public boolean isEmpty() {
        return storage.isEmpty();
    }

    @Override
    public String toString() {
        return "Stack{" +
                "storage=" + storage +
                '}';
    }
}
